<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<html>
	<head>
		<script type="text/javascript">
		
			$(function(){
				//加载两个要使用json分页的组件
		        loadGird("frm", 1);
			})
				
			//对第一个frm的回调函数, 方法的命名规则为callback_+表单id	
			var callback_frm = function(rows, frm) {
		       $.each(rows, function(i, n){
		    	   var row = $("#"+frm+" .template").clone().removeClass("template");
		           row.find(".klId").attr("value",n.id);
		       	   row.find(".klName").text(n.name);
		       	   row.find(".klLogincode").text(n.login_code);
		           row.find(".klEmail").text(n.email);
		           row.find(".klDesc").text(n.userid);
		          // row.find(".klsrole").attr("href","<%=path %>/sys/user/get/userRoles?userId="+n.id);
		           
		           row.attr("id","ready"+i);//改变绑定好数据的行的id
		           row.attr("class","tr_nbw");
		           row.appendTo("#"+frm+" .grid");//添加到模板的容器中
		       });   
		       
			}
			
			var delusers = function(){
				var options = {
				type: 'POST',
				async: false,
				dataType: 'content-type',
				success: function(msg) {
					alert("成功删除"+msg+"条记录");
					window.location.reload();
				}
				}
				if(confirm('您确认要删除吗？')){
					//提交form
				document.getElementById("frm").action="<%=path %>/sys/user/delusers";
				$('#frm').ajaxSubmit(options);
				}
			}
			
			function addusers(){
				opendailog("{src:'<%=path %>/sys/user/toEdit/0',title:'用户属性',width:600,height:390,savefunc:'savefunc'}",window);
			}
			
			function modifyusers(){
				if(checkOnlySel()){
					opendailog("{src:'<%=path %>/sys/user/toEdit/"+getCheckedObj("chk")[0].value+"',title:'用户属性',width:600,height:390,savefunc:'savefunc'}",window);
				}
			}
			
			function savefunc(frame){
				var retv = frame.contentWindow.save()
				if(retv=="success"){
					alertMsg("保存成功！");
					reloadGrid("frm", 1);
				}
				return retv;
			}
			
			function search(){
				$("#seachv").val($("#searchval").val());
				loadGird("frm");
			}
		</script>
	</head>
<body>
		<table width="100%">
			<tr>
				<td height="2px" colspan="2"></td>
			</tr>
			<tr>
				<td >&nbsp;&nbsp;&nbsp;
					<input type="text" id="searchval" value="">
					<input type="button" onclick="search();" class="button4_nbw" value="搜索" />
				</td>
				<td align="right">
				<input type="button" onclick="addusers();" class="button4_nbw" value="添加" />
				<input type="button" onclick="modifyusers();" class="button4_nbw" value="修改" />
				<input type="button" onclick="delusers();" class="button4_nbw" value="删除" />
				&nbsp;&nbsp;
				</td>
			</tr>
		</table>
		<form name="frm" method="post" style="margin: 0" action="<%=path%>/sys/user/list" id="frm">
		<input type="hidden" id="seachv" name="seachv" value="">
		<center>
		<table><tr><td height="2px"></td></tr></table>
		<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
			<thead class="th_nbw">
				<tr >
					<td width="40px">
						<input type="checkbox" class="allCheck" />
					</td>
					<td>
						姓名
					</td>
					<td>
						账号
					</td>
					<td>
						email
					</td>
					<td>
						描 述
					</td>
					<!-- 
					<td>
						操 作
					</td>
					 -->
				</tr>
			</thead>
			<tbody>
				<tr class="template klId">
					<td width="40px" class="idCheck">
						<input type="checkbox" name="chk" class="klId" />
					</td>
					<td class="klName niceTable-left"></td>
					<td class="klLogincode niceTable-left"></td>
					<td class="klEmail niceTable-left"></td>
					<td class="klDesc niceTable-left"></td>
					<!-- 
					<td >
						<a href=""  class="klsrole"/>分配角色</a>
					</td>
					 -->
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td align="right" colspan="4" >
						<img class="loading"
							src="<%=imgPath %>/large-loading.gif" width="20px"
							class="hidden" />
						<span class="pagediv"></span>
					</td>
				</tr>
			</tfoot>
		</table>
		</center>
	</form>

</body>
</html>